package com.ds.cli.command;


import cn.hutool.core.bean.BeanUtil;
import com.ds.generator.MainGenerator;
import com.ds.model.MainTemplateConfig;
import freemarker.template.TemplateException;
import lombok.Data;
import picocli.CommandLine;

import java.io.IOException;
import java.util.concurrent.Callable;

//用交互式输入就用Callable
@CommandLine.Command(name = "generate", mixinStandardHelpOptions = true)
@Data
public class GenerateCommand implements Callable {
    /**
     * 是否循环
     */
    @CommandLine.Option(names={"-l","--loop"},description = "是否循环",arity = "0..1",interactive = true,echo = true)
    private boolean loop = false;

    /**
     * 作者
     */
    @CommandLine.Option(names={"-a","--author"}, description = "作者",arity = "0..1",interactive = true,echo = true)
    private String author = "ds";

    /**
     * 输出信息
     */
    @CommandLine.Option(names={"-o","--outputText"}, description = "输出信息",arity = "0..1",interactive = true,echo = true)
    private String outputText = "输出结果:";


    @Override
    public Integer call() throws Exception {
        MainTemplateConfig mainTemplateConfig = new MainTemplateConfig();
        BeanUtil.copyProperties(this, mainTemplateConfig);
        MainGenerator.doGenerate(mainTemplateConfig);
        return 0;
    }
}
